This page last changed on Dec 02, 2014 by kgomes.

Begin forwarded message:
From: Brent Roman <brent@mbari.org>
Date: March 10, 2011 8:30:02 PM PST
To: ESP Technical Deployment Discussion List <esptech@listserver.mbari.org>, "Zhang, Yanwu" <yzhang@mbari.org>
Subject: esptech ESP event triggers

I've checked code into CVS that allows mission phases to start on conditional event triggers (per today's demo).

I did add the ability to handle lists of "ored" conditions such that the conditional phase will start when any listed are met, however, I did not add "anded" condition lists because there is no clear definition of what the ESP should do if one of those conditions terminates with an error.  For now, I'd like to propose that we leave this as is.

The example mission is checked into CVS as esp2/mission/triggerTest.rb
It does now synchronize with the CTD polling thread using like this:

:HotWater.denotes proc {
 loop {
   SensorPolling.awaitUpdate
   break if CTD.temperature >= 25
 }
}

Chris P. and I met to discuss how to handle the case where a WCR must be processed on an event that occurs while the MFB grinds in the background.  The current code indeed cannot handle this, as the ESP will not advance to the next phase conditional until the MFB is done.  I intend to remove this restriction in the coming days.

Note that this does not yet include Yanwu's peak detection logic, but is a framework for adding arbitrary conditions to start individual ESP phases.  I'll work with Yanwu next week on converting his Matlab code to ESP event triggers.


Brent Roman                                   MBARI
Software Engineer               Tel: (831) 775-1808
425 Clinton Street,            Santa Cruz, CA 95062
brent@mbari.org  http://www.mbari.org/~brent

Here is the script for MOE that the GUI should be able to generate (althought Chris said this is not the final form):

#Mission:  MOE March 2011 M0 Canon
#Nitrate and Temperature can Trigger sampling

module Threshold
  module_function
  def highNO3= highNO3um
    @highNO3 = highNO3um
    log "HighNitrate threshold set to #{highNO3um}uM"
  end
  def highNO3
    @highNO3
  end

  def lowNO3= lowNO3um
    @lowNO3 = lowNO3um
    log "LowNitrate threshold set to #{lowNO3um}uM"
  end
  def lowNO3
    @lowNO3
  end

  def hotWater= tempC
    @hotWater = tempC
    log "HotWater threshold set to #{tempC}C"
  end
  def hotWater
    @hotWater
  end

  def coldWater= tempC
    @coldWater = tempC
    log "ColdWater threshold set to #{tempC}C"
  end
  def coldWater
    @coldWater
  end
  
  def wcrDelay= time
    @wcrDelay= Delay.new time
    log "WCR will wait up to #{wcrDelay} for conditional triggering"
  end  
  def wcrDelay
    @wcrDelay
  end  
end

# initial thresholds
Threshold.highNO3=45
Threshold.lowNO3=5
Threshold.hotWater=25
Threshold.coldWater=2
Threshold.wcrDelay="6:00:00"  #6 hours


:HighNitrate.denotes proc {ISUS.no3 > Threshold.highNO3} #uM/L
:LowNitrate.denotes proc {ISUS.no3 < Threshold.lowNO3}  #uM/L

:HotWater.denotes proc {CTD.temperature > Threshold.hotWater} #C
:ColdWater.denotes proc {CTD.temperature < Threshold.coldWater}  #C

:LowNitrateAndHotWater.denotes proc {LowNitrate[] and HotWater[]}
:HighNitrateAndColdWater.denotes proc {HighNitrate[] and ColdWater[]}
:HighNitrateAndHotWater.denotes proc {HighNitrate[] and HotWater[]}

#standard, repeated mission phase
def pcrWCR(*wcrConditions)
  bacSHAmfb
  awaitEventUntil Thread.time+Threshold.wcrDelay, *wcrConditions
  standAloneWCR ([nil, 1000], $bac) {hotBleach :waste2b}
  Sleep.awaitBackgroundThreads {
    Log.record "Extending phase until #{Sleep.backgroundNames} finish(es)"
  }
end


#$startTime = nil  #don't override start time of initial phase

mission :startTube=>2, :until=>"6AM 5/2/11" do 


  at "1PM 3/31/11" do
    pcrWCR
  end
  

  at "9AM 4/3/11", or: HighNitrate do
    pcrWCR ColdWater
  end

  
end

Document generated by Confluence on Feb 03, 2026 14:16